import { defineStore } from 'pinia'
import {
  getCategory1,
  getCategory2,
  getCategory3,
} from '@/api/product/attr/attr'
import type { categoryData } from './types/type'
const useCategory = defineStore('Category', {
  state: (): categoryData => {
    return {
      c1List: [],
      c1Id: '',

      c2List: [],
      c2Id: '',
      c3List: [],
      c3Id: '',
    }
  },
  actions: {
    async getC1() {
      const res = await getCategory1()
      if (res.code == 200) {
        this.c1List = res.data || []
      }
    },
    async getC2() {
      const res = await getCategory2(this.c1Id)
      if (res.code == 200) {
        this.c2List = res.data || []
      }
    },
    async getC3() {
      const res = await getCategory3(this.c2Id)
      if (res.code == 200) {
        this.c3List = res.data || []
      }
    },
  },
  getters: {},
})
export default useCategory
